{% extends "base.html" %}

{% block title %}{% endblock %}

{% block content %}

<div id="main_content" class="right">
	<div id="recent_recalls" class="sec">
		<ul>
			{% for r in recalls %}
			<li>
				<div class="date left">{% ifchanged %}{{ r.when|date:"N j Y" }}{% endifchanged %}&nbsp;</div>
				<div class="info left">
					<div class="product">
						{% if r.description %}{{ r.description|safe }}{% else %}{{ r.brand_name|safe }}{% endif %} &mdash; 
						<a href="{% url recallviewer.views.company_view r.company.id %}">{{ r.company.name|safe }}</a></div>
					<div class="reason">{{ r.reason|default:"Unknown" }}</div>
					<div class="summary">{{ r.summary|default:""|truncatewords:20|safe }}</div>
					<div class="press_release small">
						<a href="{% url recallviewer.views.recall_view r.id %}">#</a> / 
						Press release: {{ r.release_link|safe|urlizetrunc:20 }}
						{% if r.photo_link %}/ Photo: {{ r.photo_link|safe|urlizetrunc:20 }}{% endif %}
					</div>
				</div>
				<div class="clr"></div>
			</li>
			{% endfor %}
		</ul>
	</div><!-- @end recent_recalls -->
</div><!-- @end main_content -->

<div id="sidebar_content" class="left">
	
	<div id="aggregates" class="sec">
		<div id="recalls_this_month" style="padding-bottom:20px;margin-bottom:20px">
			<h2>Recalls this Month</h2>
			<div class="big">{{ recalls_this_month }}</div>
		</div>

		<div id="recalls_this_year">
			<h2>Recalls this Year</h2>
			<div class="big">{{ recalls_this_year }}</div>
		</div>
	</div>

	<div id="recalls_by_month" class="sec">
		<h2>Recalls by Month</h2>
		<ul class="timeline">
		{% for year, month, count in recalls_by_month %}
		<li>
			<a href="{% url recallviewer.views.month_view year,month %}" title="{{ count }}">
				<span class="label">{{ month }}</span>
				{% ifchanged %}{% ifequal year 2010 %}<span class="year">{{ year }}</span>{% endifequal %}{% endifchanged %}
				<span class="count" style="height: {% widthratio count 60 100 %}%;">({{ count }})</span>
			</a>
		</li>
		{% endfor %}
		</ul>
	</div><!-- @end recalls_by_month -->

	<div id="worst_companies" class="sec">
		<h2>Companies with Most Recalls</h2>
		<ul class="chartlist">
		{% for c in companies %}
		<li>
			<a href="{% url recallviewer.views.company_view c.id %}">{{ c.name|safe }}</a>
			<span class="count">{{ c.num_recalls }}</span>
			<span class="index" style="width: {% widthratio c.num_recalls 15 270 %}px;">({% widthratio c.num_recalls 15 100 %}%)</span>
		</li>
		{% endfor %}
		</ul>
		
		<br />
		<small><em>* Since 2009</em></small>
	</div><!-- @end worst_companies -->

	<div id="common_reasons" class="sec">
		<h2>Leading Reasons</h2>
		<ol>
			{% for r in reasons%}
			<li>
				{{ r.reason }} <span class="meta">({{ r.reason__count }})</span>
			</li>
			{% endfor %}
		</ul>
	</div><!-- @end common_reasons -->
	
</div><!-- @end sidebar_content -->

{% endblock %}